﻿<!--头部文件-->
<include file="Public/header"/>
<!--头部文件结束-->


<div class="wrapper">
    <!--左侧菜单栏-->
    <include file="Public/menu"/>
    <!--左侧菜单栏结束-->

    <div class="main-panel">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-minimize">
                    <button id="minimizeSidebar" class="btn btn-warning btn-fill btn-round btn-icon">
                        <i class="fa fa-ellipsis-v visible-on-sidebar-regular"></i>
                        <i class="fa fa-navicon visible-on-sidebar-mini"></i>
                    </button>
                </div>
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">产品编辑</a>
                </div>
            </div>
        </nav>


        <div class="content">
            <div class="container-fluid">

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <form id="edit_form" class="form-horizontal" action="__APP__/Dynamic/edit_form/id/{$dynamic.id}/type/{$url}" method="post" enctype="multipart/form-data">
                                <div class="content">
                                    <legend>产品编辑</legend>

                                    <fieldset>
                                        <div class="form-group" >
                                            <label class="col-sm-2 control-label">标识图片</label>
                                            <div class="col-sm-6" style="width:10%">
                                                <input id="dynamic_add_img" onclick="$('#select_img').click()" type="button" value="选择图片" style="width:100%;height:30px;background:white;border:1px solid #ccc">
                                                <input name="logo" id="select_img" type="file" style="display:none">
                                            </div>
                                            <div class="col-sm-6"><code style="margin-top:4px">请使用jpg、png、gif格式的图片,且不能超过2M.</code></div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group" style="height:100px;line-height:100px;">
                                            <label class="col-sm-2 control-label">图片预览</label>
                                            <div class="col-sm-6">
                                                <img id="show_img" src="__ROOT__/{$dynamic.path}" style="width:180px;height:100px;">
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">产品标题</label>
                                            <div class="col-sm-6">
                                                <input value="{$dynamic.title}" class="form-control" id="title" type="text" name="title" number="true" style="width:121%;" onkeyup="value=value.replace(/[^\S]+/g,'')"/>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">文章简介</label>
                                            <div class="col-sm-6">
                                                <textarea class="form-control" id="profile" name="profile" style="resize:none;width:121%">{$dynamic.profile}</textarea>
                                            </div>
                                        </div>
                                    </fieldset>

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">产品正文</label>
                                            <div class="col-sm-6">
                                                <script name='content' id="editor" type="text/plain" style="width:110%;height:500px;">{$dynamic.content}</script>
                                                <script type="text/javascript">
                                                var ue = UE.getEditor('editor');
                                                </script>
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
                                <div class="footer text-left">
                                    <button id="button_yes" type="button" class="btn btn-info btn-fill">提交</button>
                                    <button id="button_no" type="button" onclick="window.location.href='__APP__/Dynamic/{$url}/suc/{$url}.html'" class="btn btn-info btn-fill">返回</button>
                                </div>
                                <br/>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!--底部文件-->
        <include file="Public/footer"/>
        <!--底部文件结束-->


    </div>
</div>

</body>

<!--   Core JS Files and PerfectScrollbar library inside jquery.ui   -->
<script src="__ROOT__/public/js/jquery.min.js" type="text/javascript"></script>
<script src="__ROOT__/public/js/jquery-ui.min.js" type="text/javascript"></script>
<script src="__ROOT__/public/js/bootstrap.min.js" type="text/javascript"></script>


<!--  Forms Validations Plugin -->
<script src="__ROOT__/public/js/jquery.validate.min.js"></script>
<!--  Plugin for Date Time Picker and Full Calendar Plugin-->
<script src="__ROOT__/public/js/moment.min.js"></script>
<!--  Date Time Picker Plugin is included in this js file -->
<script src="__ROOT__/public/js/bootstrap-datetimepicker.js"></script>
<!--  Select Picker Plugin -->
<script src="__ROOT__/public/js/bootstrap-selectpicker.js"></script>
<!--  Checkbox, Radio, Switch and Tags Input Plugins -->
<script src="__ROOT__/public/js/bootstrap-checkbox-radio-switch-tags.js"></script>
<!--  Charts Plugin -->
<script src="__ROOT__/public/js/chartist.min.js"></script>
<!--  Notifications Plugin    -->
<script src="__ROOT__/public/js/bootstrap-notify.js"></script>
<!-- Sweet Alert 2 plugin -->
<script src="__ROOT__/public/js/sweetalert2.js"></script>
<!-- Vector Map plugin -->
<script src="__ROOT__/public/js/jquery-jvectormap.js"></script>
<!--  Google Maps Plugin    -->
<script src="__ROOT__/public/js/aa743e8f448a4792bad10d201a7080f6.js"></script>
<!-- Wizard Plugin    -->
<script src="__ROOT__/public/js/jquery.bootstrap.wizard.min.js"></script>
<!--  Bootstrap Table Plugin    -->
<script src="__ROOT__/public/js/bootstrap-table.js"></script>
<!--  Plugin for DataTables.net  -->
<script src="__ROOT__/public/js/jquery.datatables.js"></script>
<!--  Full Calendar Plugin    -->
<script src="__ROOT__/public/js/fullcalendar.min.js"></script>
<!-- Light Bootstrap Dashboard Core javascript and methods -->
<script src="__ROOT__/public/js/light-bootstrap-dashboard.js"></script>
<!--   Sharrre Library    -->
<script src="__ROOT__/public/js/jquery.sharrre.js"></script>
<!-- Light Bootstrap Dashboard DEMO methods, don't include it in your project! -->
<script src="__ROOT__/public/js/demo.js"></script>
<script src="__ROOT__/public/js/new_js.js"></script>
<script>
    $('li.Dynamic').addClass('active');
    $('a.Dynamic-a').attr('aria-expanded','true');
    $('div.Dynamic-div').addClass('in');
    $('li.Dynamic-{$url}').addClass('active');

    $('#dynamic_add_img').mouseover(function(){
        $(this).css('background','#ccc');
    })
    $('#dynamic_add_img').mouseout(function(){
        $(this).css('background','white');
    })

    $('#button_yes').click(function(){
        if($('#select_img').val()=='' && $('#show_img').attr('src')!='__ROOT__/{$dynamic.path}'){
            One_button('请选择图片');
        }else if($('#title').val()==''){
            One_button('请输入标题');
        }else if($('#profile').val()==''){
            One_button('请输入文章简介');
        }else if(ue.getContent()==''){
            One_button('请填入正文内容');
        }else{
            edit();
            $('#edit_form').submit();
        }
    })

    //图片上传预览
    $(function(){
        $('#select_img').on('change',function(){
            var imgfile =this.files[0];
            var fr= new FileReader();
            fr.onload=function(){
                $('#show_img').attr('src',fr.result);
                $('#show_img').css({"width":"180px","height":"100px"});
            }
            fr.readAsDataURL(imgfile);
        });
    })
    $('#select_img').change(function(){
        $('#show_img').css('display','');
        if($(this).val()==''){
            $('#show_img').css('display','none');
        }
    })

    $('#menu option[value={$dynamic.menu}]').prop('selected','selected');

    /* 数据库修改减少优化 */
    function edit(){
        if($('#show_img').attr('src')=='__ROOT__/{$dynamic.path}'){
            $('#select_img').removeAttr('name');
        }
        if($('#title').val()=="{$dynamic.title}"){
            $('#title').removeAttr('name');
        }
        if($('#profile').val()=="{$dynamic.profile}"){
            $('#profile').removeAttr('name');
        }
    }
</script>
</html>
